<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org"><!-- 引入命名空间 -->
<head>
	<title>山朴奈竞赛</title>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"></link>
	<link rel="stylesheet" th:href="@{/css/common.css}">


    <style>
        table {
            border-collapse: collapse;
            width: 100%;
        }

        th,
        td {
            border: 1px solid #dddddd;
            text-align: left;
            padding: 8px;
        }

        th {
            background-color: #f2f2f2;
        }
		a {
		    color: rgb(128, 128, 128);
		    text-decoration: none;
		    margin-left: 15px;
		    transition: color 0.3s ease;
		}

		a:hover {
		    color: rgb(0, 0, 64);
		}

    </style>
</head>

<body>
		<div class="nav">

		<h5>山朴奈</h5>
		
		<div class="spacer"></div>
		<a th:href="@{/}">首页</a>
		<a th:href="@{/user/oneself}">修改信息</a>
		<a th:href="@{/contest/view}">竞赛项目列表</a>
		<a th:href="@{/team/list}">竞赛队伍列表</a>
		<a th:href="@{/picture/list}">上传获奖证书</a>
		<a th:unless="${user!= null}" th:href="@{/application/listStudent}">我的竞赛</a>
		<a th:href="@{/login}">登录管理</a>

		</div>
	<!--	<div class="container"> -->
    <h1>contest list </h1>
    <table>
		<thead>
        <tr>
            <th>项目id</th>
            <th>项目名称</th>
            <th>操作</th>
        </tr>
		</thead>
        <!-- 使用Thymeleaf或者其他模板引擎语法来遍历数据，这里假设使用Thymeleaf -->
		<tbody>
        <tr th:each="contest : ${pageContest.content}">
            <td th:text="${contest.id}"></td>
            <td th:text="${contest.content}"></td>
            <td>
                <a th:href="@{/team/addteam(contestId=${contest.id})}">创建队伍</a>
                <a th:unless="${session.user.id==5}" th:href="@{/team/jointeam(contestId=${contest.id})}">加入队伍</a>
				<a th:unless="${session.user.id!=5}" th:href="@{/contest/delete(contestId=${contest.id})}" role="button" onclick="return confirm('确定要删除吗？')">删除</a></td>
        </tr>
		</tbody>
    </table>
    <div>
        <a th:unless="${session.user.id!=5}" href="/contest/toadd">添加竞赛项目</a>
        <!--<a href="/contest/search">查找项目</a>-->
		<form action="#" th:action="@{/contest/return}" method="get">
		     <label for="contestId">输入竞赛ID:</label>
		     <input type="number" id="contestId" name="contestId" required />
		     <input type="submit" value="查找" />
		 </form>
    </div>
	
    <div>
        <!-- 如果有分页导航的需求，可以添加以下逻辑 -->
        <span>Page: [[${pageContest.number + 1}]] of [[${pageContest.totalPages}]]</span><br>

        <a th:if="${pageContest.number > 0}" th:href="@{/contest/view(page=${pageContest.number-1})}">上一页</a>
		<a th:if="${pageContest.number < pageContest.totalPages-1}" th:href="@{/contest/view(page=${pageContest.number+1})}">下一页</a>    
	</div>

      
    </div>

</body>

</html>